﻿using Janus.Mes.POCO;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using vm.Aspects.ExpressionSerialization;

namespace Tests.Janus.Mes.SqlDal.ConsWrite.dal
{
    public class ExpressTreeTest
    {
        public ExpressTreeTest()
        {
            Ttest();
        }
        public void Ttest()
        {
            // MulitThreadsFactory.TestConcurrency(() => {
            Indicator model = new Indicator();
            string m1 = "0";
            while (1 == 1)
            {
                Stopwatch w = new Stopwatch();
                w.Start();
                //Expression<Func<TestModel, bool>> e = c => c.M1== m1;
                var e = System.Linq.Dynamic.DynamicExpression.ParseLambda<Indicator, bool>("IndicatorName.IndexOf(@0)>0", m1);
                //var result = XmlExpressionSerializer.ToXmlElement(e);
                var result = new XmlExpressionSerializer().ToXmlDocument(e);
                w.Stop();
                var time = w.ElapsedMilliseconds;
                Trace.WriteLine("ToXmlElement:" + time);

                Stopwatch w2 = new Stopwatch();
                w2.Start();
                var e2 = XmlExpressionSerializer.ToExpression(result);
                w2.Stop();
                var time2 = w2.ElapsedMilliseconds;
                Trace.WriteLine("ToExpression:" + time2);

            }
            // }, 1);


        }
    }
}
